{% extends 'TopxiaAdminBundle::layout.html.twig' %}

{% set menu = 'admin_user_manage' %}

{% set script_controller = 'user/list' %}

{% block main %}

  {{ web_macro.flash_messages() }}

  <form id="user-search-form" class="form-inline well well-sm" action="" method="get" novalidate>
    <div class="mbm">

      {% include 'OrgBundle:Org:org-tree-select.html.twig' with {orgCode: app.request.get('orgCode'), modal: 'list'} %}

      <select class="form-control" name="datePicker" id="datePicker">
        {{ select_options({longinDate:'登录时间'|trans, registerDate: '注册时间'|trans}, app.request.get('datePicker') ,'--时间类型--'|trans) }}
      </select>
      <div class="form-group ">
        <input class="form-control" type="text" id="startDate" name="startDate"
               value="{{ app.request.query.get('startDate') }}" placeholder="{{ '起始时间'|trans }}">
        -
        <input class="form-control" type="text" id="endDate" name="endDate"
               value="{{ app.request.query.get('endDate') }}" placeholder="{{ '结束时间'|trans }}">
      </div>
    </div>
    <div class="form-group">

      <select class="form-control" name="roles">
        {{ select_options(dict('userRole')|array_merge(allRoles), app.request.query.get('roles'), '--所有角色--'|trans) }}
      </select>
    </div>

    <span class="divider"></span>
    <div class="form-group">
      <select id="keywordUserType" name="keywordUserType" class="form-control">
        {{ select_options(dict('userType'), app.request.query.get('keywordUserType'), '--注册来源--'|trans) }}
      </select>
    </div>

    <div class="form-group">
      <select id="keywordType" name="keywordType" class="form-control">
        {{ select_options(dict('userKeyWordType'), app.request.query.get('keywordType') ? app.request.query.get('keywordType') : 'nickname') }}
      </select>
    </div>

    <div class="form-group">
      <input type="text" id="keyword" name="keyword" class="form-control" value="{{ app.request.query.get('keyword') }}"
             placeholder="{{ '关键词'|trans }}">
    </div>

    <button class="btn btn-primary">搜索</button>

    {% if has_permission('admin_user_export') and is_plugin_installed('UserImporter') %}
      <a class="btn btn-primary mhs" id="user-export" data-toggle="modal" data-target="#modal"
         data-url="{{ path('admin_user_export') }}">{{ '导出搜索结果'|trans }}</a>
    {% endif %}

  </form>



  <table id="user-table" class="table table-striped table-hover" data-search-form="#user-search-form">
    <thead>
    <tr>
      <th>{{ '用户名'|trans }}</th>
      {% include 'OrgBundle:Org/Parts:table-thead-tr.html.twig' %}
      <th>{{ '手机号'|trans }}</th>
      <th>Email</th>
      <th>{{ '注册时间'|trans }}</th>
      <th>{{ '最近登录'|trans }}</th>
      <th width="10%">{{ '操作'|trans }}</th>
    </tr>
    </thead>
    <tbody>
    <p class="text-muted">
      <span class="mrl">{{ '用户总数：'|trans }}<strong class="inflow-num">{{ userCount }}</strong></span>
    </p>
    {% for user in users %}
      {% include 'TopxiaAdminBundle:User:user-table-tr.html.twig' with {user:user,profile:profiles[user.id]} %}
    {% endfor %}
    </tbody>
  </table>
  {% include 'OrgBundle:Org:batch-update-org-btn.html.twig' with {module:'user', formId:'user-table'} %}
  {{ admin_macro.paginator(paginator) }}
{% endblock %}